#include <stdio.h>  
#include <math.h>  
  
int mValid[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};  
  
int main() {  
    int y, m, d, x;  
    if (scanf("%d%d%d", &y, &m, &d));  
    x = (y - 1900) % 4 == 0 ? m <= 2 ? -1 : 0 : 0;  
    if (m < 1 || m > 12) {  
        printf("month is error.\n");  
        return 0;  
    }  
  
    if (mValid[m] < d || d < 0) {  
        if (((y % 4 == 0 && y % 100 != 0) || y % 400 == 0) && m == 2 && d == 29);  
        else {  
            printf("day is error.\n");  
            return 0;  
        }  
  
    }  
    switch (m) {  
        case 1:  
            m = 0;  
            break;  
        case 2:  
            m = 31;  
            break;  
        case 3:  
            m = 31 + 28;  
            break;  
        case 4:  
            m = 31 + 28 + 31;  
            break;  
        case 5:  
            m = 31 + 28 + 31 + 30;  
            break;  
        case 6:  
            m = 31 + 28 + 31 + 30 + 31;  
            break;  
        case 7:  
            m = 31 + 28 + 31 + 30 + 31 + 30;  
            break;  
        case 8:  
            m = 31 + 28 + 31 + 30 + 31 + 30 + 31;  
            break;  
        case 9:  
            m = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31;  
            break;  
        case 10:  
            m = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30;  
            break;  
        case 11:  
            m = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31;  
            break;  
        case 12:  
            m = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30;  
            break;  
    }  
  
    d += (y - 1900) / 4 - (y - 1900) / 100 + (y - 1900) / 400;  
    printf("%d\n", ((y - 1900) * 365 + m + d + 1 + x) % 7);  
    return 0;  
}  